#include<stdio.h>
#include<string.h>
#define FAIL    0x00
#define SUCCESS 0xFF
typedef struct 
{
	int Number;
	int WorkId;
	char Name[20];
	char Sex[10];
	int age;
	char PhoneNumber[20];
	char HouseholdRegister[100];
} OfficeWorker_t;
const OfficeWorker_t WorkInfo[5] = 
{
    {1, 60001, "Xiaoming",  "Male",   34, "16677789076", "Shanghai" },
    {2, 60012, "XiaoLi",    "Female", 29, "17767812312", "Jiangsu"  },
    {3, 60106, "Xiaoqiang", "Male",   30, "18910023897", "Hubei"    },
    {4, 60113, "Xiaowang",  "Male",   38, "17776388990", "Hubei"    },
    {5, 60128, "Xiaoyu",    "Male",   38, "16090077882", "Xinjiang" },
};   //定义OfficeWorker_t类型的结构体数组
int main(void)
{
    int i;  
    int IdToSearch;                 //搜索的ID
    int SearchResult = FAIL;        //搜索结果
    int SearchResultIndex = 0;      //搜索成功的Index
    printf("Input the worker's ID you want to search:");
    scanf("%d", &IdToSearch);
    /*遍历表*/
    for(i = 0; i < 5; i ++)
    {
        if(WorkInfo[i].WorkId == IdToSearch)
        {
            SearchResult = SUCCESS;
            SearchResultIndex = i;
            break;
        }
    }
    if(SearchResult == SUCCESS)
    {
        printf("\t%d\t%d\t%-20s\t%s\t%d\t%s\t%s\n", WorkInfo[SearchResultIndex].Number, WorkInfo[SearchResultIndex].WorkId,   \
                                                    WorkInfo[SearchResultIndex].Name, WorkInfo[SearchResultIndex].Sex,        \
                                                    WorkInfo[SearchResultIndex].age, WorkInfo[SearchResultIndex].PhoneNumber, \
                                                    WorkInfo[SearchResultIndex].HouseholdRegister);
    }
    else
    {
        printf("The worker is not found\n");
    }

}

